package per.turtle.system.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import per.turtle.common.core.annotation.MaxSizeWithCharset;
import per.turtle.common.core.web.entity.BaseEntity;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
 * @author turtle
 */
@ApiModel(value = "SysMenu", description = "菜单权限")
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_menu")
@ToString
public class SysMenu extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("菜单ID")
    @TableId(type = IdType.ASSIGN_UUID)
    private String menuId;

    @ApiModelProperty("菜单名称")
    @NotBlank(message = "菜单名称不能为空")
    @MaxSizeWithCharset(max = 63, message = "菜单名称超出限定长度！")
    private String menuName;

    @ApiModelProperty("父菜单名称")
    @TableField(exist = false)
    private String parentName;

    @ApiModelProperty("父菜单ID")
    private String parentId;

    @ApiModelProperty("显示顺序")
    @Max(value = 9999, message = "显示顺序取值范围在4位数以内")
    @Min(value = 1, message = "显示顺序取值需大于0")
    @NotNull(message = "显示顺序不能为空")
    @OrderBy(asc = true)
    private Integer orderNum;

    @ApiModelProperty("路由地址")
    @MaxSizeWithCharset(max = 200, message = "路由地址超出限定长度！")
    private String path;

    @ApiModelProperty("组件路径")
    @MaxSizeWithCharset(max = 200, message = "组件路径超出限定长度！")
    private String component;

    @ApiModelProperty("是否为外链")
    private Boolean isFrame;

    @ApiModelProperty("是否缓存")
    private Boolean isCache;

    @ApiModelProperty("类型（ML：目录；CD：菜单；AN：按钮）")
    @NotBlank(message = "菜单类型不能为空")
    private String menuType;

    @ApiModelProperty("是否显示")
    private Boolean visible;

    @ApiModelProperty("是否停用")
    private Boolean isDisabled;

    @ApiModelProperty("权限字符串")
    @MaxSizeWithCharset(max = 100, message = "权限标识超出限定长度！")
    private String perms;

    @ApiModelProperty("菜单图标")
    private String icon;

    @ApiModelProperty("子菜单")
    @TableField(exist = false)
    private List<SysMenu> children = new ArrayList<>();

}
